package shuzhiStream;

import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @Author wangtengyu
 * @Create 2018-06-06-15:11
 */
public class gougu {

    public static void main(String[] args) {

//        Stream<int[]> stream = IntStream.rangeClosed(1, 100).boxed()
//                .flatMap(a -> IntStream.rangeClosed(a, 100)
//                        .filter(b -> Math.sqrt(a * a + b * b) % 1 == 0)
//                        .mapToObj(b -> new int[]{a, b, (int) Math.sqrt(a * a + b * b)})
//                );
//        stream.limit(5).forEach(t -> System.out.println(t[0] + " " + t[1] + " " + t[2]));


        Stream<double[]> stream2 = IntStream.rangeClosed(1, 100).boxed()
                .flatMap(a -> IntStream.rangeClosed(a, 100)
                        .mapToObj(b -> new double[]{a, b, Math.sqrt(a * a + b * b)})
                        .filter(t -> t[2] % 1 == 0)
                );
        stream2.limit(5).forEach(t -> System.out.println(t[0] + " " + t[1] + " " + t[2]));
    }


}
